//
//  Client.m
//  VidAgent
//
//  Created by Andre Kasper on 24.05.11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#include "VidSenderProt.h"
#import "Client.h"


@implementation Client

-(void) startClient:(NSString *)s {
	NSAutoreleasePool *pool;
	
	id <VidSender> reader;
	
	NSString *file;
	
	pool = [NSAutoreleasePool new];
	
	reader = (id <VidSender>)[NSConnection
							  rootProxyForConnectionWithRegisteredName: @"my_server" 
							  host: s
							  usingNameServer: [NSSocketPortNameServer sharedInstance]];
	
	if (reader == nil) {
		NSLog (@"Error: could not connect to server");
		exit (1);
    }
	
	file = [reader send];
	
	if (file != nil) {
		printf ("%s\n", [file cString]);
		[reader set:@"test"];
		[reader print];
    } else {
		NSLog (@"Error: could not read file `%@'", file);
		exit (1);
	}
}

@end
